#include <limits.h>
#include "gtest/gtest.h"
#include "../include/DataSource.h"
#include "../include/JsonParser.h"
#include "subs/DataSourceSub.h"
#include <vector>
//#include "./subs/HttpClientSub.h"
//#include "../include/WindowsHttpClient.h"
#define MBYTE 1024*1024
// Tests factorial of negative numbers.
TEST(JsonParserTest,ParseDataSourceStatus) {
	// This test is named "Negative", and belongs to the "FactorialTest"
	// test case.
	JsonParser* parser=new JsonParser();
	DataSource* dataSource=new DataSourceSub();
	char* buffer=new char[MBYTE*10];
	int nBufferSize=MBYTE*10;
	int result=dataSource->GetStatusJson(buffer,nBufferSize);
	DataSourceStatus status=parser->ParseDataSourceStatus(buffer);

	ASSERT_TRUE(status.IsRuning());
	ASSERT_EQ("1326351373900",status.GetCacheTimeStamp());

}

TEST(JsonParserTest,ParseSlots) {
	// This test is named "Negative", and belongs to the "FactorialTest"
	// test case.
	JsonParser* parser=new JsonParser();
	DataSource* dataSource=new DataSourceSub();
	char* buffer=new char[MBYTE*10];
	int nBufferSize=MBYTE*10;
	int result=dataSource->GetSlotsJson(buffer,nBufferSize);
	std::vector<Slot> slots =parser->ParseSlots(buffer);

	ASSERT_EQ(3,slots.size());
}

TEST(JsonParserTest,ParseAdList) {
	// This test is named "Negative", and belongs to the "FactorialTest"
	// test case.
	JsonParser* parser=new JsonParser();
	DataSource* dataSource=new DataSourceSub();
	char* buffer=new char[MBYTE*10];
	int nBufferSize=MBYTE*10;

	int result=dataSource->GetAdListJson(1,10,buffer,nBufferSize);
	//vector<Slot> slots =parser->ParseSlots(buffer);

	//ASSERT_EQ(DataSource::DATA_SOURCE_STATUS_STOP,status);
}